const mongoose = require('mongoose')
const {formatDate} = require('../../utils')
const WebSocketSchema = new mongoose.Schema({
    siteName: { type: String, required: true, trim: true},
    url: { type: String, trim: true },
    secret: {type: String, required: true, unique:true, trim: true},
    userId: {type: String, required: true},
    username: {type: String, required: true},
    ctime: { type: String, required: true, default: formatDate() },
    num: {type: String, required: true, default: '0'}, //当前连接数
    status: {type: Number, required: true, min: 1, max: 2, default: 1}, //1开启监控 2停止监控
}) 

const WebSocket = mongoose.model('webSockets', WebSocketSchema)

module.exports = WebSocket